﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SLPropertyGrid.System.ComponentModel;

namespace TestUI
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            Person p = new Person();
            p.String = "John Lennon";
            p.Datetime = new DateTime(1940, 10, 9);
            p.Int = -42;
            p.Short = 21;
            p.Long = -2878987;
            p.Uint = 324;
            p.Ushort = 21;
            p.Ulong = 21422;
            p.Car = new Car();

            propGrid.Instance = theButton;
            propGrid2.Instance = p;
        }
        private void LayoutRoot_BindingValidationError(

       object sender, ValidationErrorEventArgs e)
        {

        }

        private void theButton_Click(object sender, RoutedEventArgs e)
        {
            propGrid.ExploreVisualTree();
        }
    }

    public class Person
    {
        [Category("Numeric Float")]
        public double Double { get; set; }
        [Category("Numeric Float")]
        public decimal Decimal { get; set; }
        [Category("Numeric Signed")]
        public int Int { get; set; }
        [Category("Numeric Signed")]
        public short Short { get; set; }
        [Category("Numeric Signed")]
        public long Long { get; set; }
        [Category("Numeric Unsigned")]
        public uint Uint { get; set; }
        [Category("Numeric Unsigned")]
        public ushort Ushort { get; set; }
        [Category("Numeric Unsigned")]
        public ulong Ulong { get; set; }
        [Category("Read Only")]
        [DisplayName("The answer to everything")]
        public double Answer
        {
            get
            {
                return 42;
            }
        }
        [Category("Read Only")]
        public DateTime Now
        {
            get { return DateTime.Now; }
            
        }
        [Category("Read Only")]
        public bool True
        {
            get { return true; }
            
        }
        [Category("Read Only")]
        public DayOfWeek Today
        {
            get { return DateTime.Now.DayOfWeek; }
            
        }
        [Category("Strings")]
        public string String
        {
            get;
            set;
        }
        [Category("Strings")]
        public char Char { get; set; }

        [Category("Date & Time")]
        public DateTime Datetime
        {
            get;
            set;
        }
        [Category("Date & Time")]
        public TimeSpan TimeSpan
        {
            get;
            set;
        }
        [Category("Others")]
        public bool Boolean
        {
            get;
            set;
        }

        [Category("Others")]
        public Car Car
        {
            get;
            set;
        }


        [Category("Others")]
        public DayOfWeek Enum
        {
            get;
            set;
        }



    }

    public class Car
    {
        public string Brand { get; set; }
        public CarType Type { get; set; }

        public enum CarType
        {
            Sport,
            StationWagon,
            SUV
        }
    }
}
